package com.yj.springbootaop.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyInvocationHandler implements InvocationHandler {

    private Object target;

    public MyInvocationHandler(Object target){
        this.target = target;
    }
    /**
     *
     * @param proxy 代理类
     * @param method 原始对象的方法
     * @param args 方法的参数
     * @return
     * @throws Throwable
     */
    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

        System.out.println("before method ");
        Object invoke = method.invoke(target,args);
        System.out.println("after method");
        return invoke;
    }
}
